package com.gexiaobao.pigeon.ui.fragment.mine.message

import android.os.Bundle
import androidx.fragment.app.Fragment
import com.gexiaobao.pigeon.R
import com.gexiaobao.pigeon.app.base.BaseFragment
import com.gexiaobao.pigeon.app.ext.initClose
import com.gexiaobao.pigeon.databinding.FragmentMessageListBinding
import com.gexiaobao.pigeon.ui.adapter.MyPagerAdapter
import com.gexiaobao.pigeon.ui.home.HomeViewModel
import me.hgj.jetpackmvvm.ext.nav

/**
 * @Author      : hxw
 * @Date        : 2023/5/31 15:18
 * @Describe    : 查看全部- 我的消息
 */
class FragmentMessageList : BaseFragment<HomeViewModel, FragmentMessageListBinding>() {

    override fun initView(savedInstanceState: Bundle?) {
        mDatabind.includeBar.toolbar.initClose(getString(R.string.mine_fragment_my_message)) {
            nav().navigateUp()
        }
    }

    override fun initData() {
        super.initData()
        val fragmentList = ArrayList<Fragment>()
        val titleList = ArrayList<String>()
        fragmentList.add(MineMessageListFragment.newInstance())
        fragmentList.add(MineMessageRaceListFragment.newInstance())
        fragmentList.add(MineMessageNoticeListFragment.newInstance())

        titleList.add("全部")
        titleList.add("比赛")
        titleList.add("公告")

        mDatabind.viewpager.adapter =
            context?.let { MyPagerAdapter(childFragmentManager, it, fragmentList, titleList) }
        mDatabind.viewpager.offscreenPageLimit = 3
        mDatabind.tablayout.setupWithViewPager(mDatabind.viewpager)
    }
}